package dao;

public class QueryFilter {

	private Sort sort;

	private int limit = -1;

	public QueryFilter() {

	}

	public QueryFilter(Sort sort, int limit) {
		setLimit(limit);
		setSort(sort);
	}

	public QueryFilter(Sort sort) {
		setSort(sort);
	}

	public QueryFilter(int limit) {
		setLimit(limit);
	}

	public Sort getSort() {
		return sort;
	}

	public void setSort(Sort sort) {
		this.sort = sort;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public boolean isSortIsDefined() {
		if (sort != null) {
			return true;
		} else {
			return false;
		}
	}

	public String getSortQuery() {

		if (isSortIsDefined()) {
			return sort.getSortQuery();
		} else {
			return "";
		}
	}

	public boolean isLimitIsDefined() {

		if (limit != -1) {
			return true;
		} else {
			return false;
		}
	}

	public String getLimitQuery() {

		if (isLimitIsDefined()) {
			return "LIMIT 0, " + limit;
		} else {
			return "";
		}
	}
}
